package com.demo.swagger;


import com.alibaba.fastjson.JSON;

import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;

/**
 * Created by Samuel on 16/7/6.
 */

@Controller
public class BaseController {

    private static Logger logger = LogManager.getLogger(BaseController.class.getName());

    public void HandleRequest(HttpServletRequest request,HttpServletResponse response) {

    }
    /**
     * 拼接返回数据 格式
     * @param response
     * @param model
     * @return
     * @throws IOException
     */
    public HttpServletResponse SetResponseFromCame(HttpServletResponse response,
                                           Object model) throws IOException {
        if (model==null)
        {
            return null;
        }
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write(JSON.toJSONString(model));
        return response;
    }

    /**
     * 防止同一个ip 重复提交相同数据
     * @param ip
     * @return f
     */

}

